home *** CD-ROM | disk | FTP | other *** search
/ World of Education / World of Education.iso / world_x / xcoral16.zip / MENUS.H < prev    next >
C/C++ Source or Header  |  1993-01-15  |  4KB  |  143 lines

  1. /*
  2. ** Copyright 1989, 1992 by Lionel Fournigault
  3. **
  4. ** Permission to use, copy, and distribute for non-commercial purposes,
  5. ** is hereby granted without fee, providing that the above copyright
  6. ** notice appear in all copies and that both the copyright notice and this
  7. ** permission notice appear in supporting documentation.
  8. ** The software may be modified for your own purposes, but modified versions
  9. ** may not be distributed.
  10. ** This software is provided "as is" without any expressed or implied warranty.
  11. **
  12. **
  13. */
  14.  
  15. #ifndef _MENUS_H_
  16. #define _MENUS_H_
  17.  
  18. #include <X11/Xlib.h>
  19.  
  20. #define     SHADOW 
  21. #define     DEPTH_UP    0
  22. #define     DEPTH_DOWN    1
  23. #define     DEPTH_WIDTH    1
  24.  
  25. #define    MAX_MENUS    15
  26. #define     MAX_ITEMS    30
  27. #define    MENU        1
  28. #define     ITEM        0
  29. #define    SHAD        5
  30. #define     BAR_SPACE    12
  31.  
  32. /*
  33.  *    Structure de sauvegarde du contexte courant.
  34.  */
  35. typedef struct {
  36.     Window    w;        /* La fenetre mappee */
  37.     int    type;        /* Menu ou item */
  38.     int    no_m, no_i;    /* Le numeros correspondants */
  39. } SWindow;
  40.  
  41. /*
  42.  *     Les ressources.
  43.  */
  44. typedef struct {
  45.     GC    ngc;    /* GC normal */
  46.     GC    igc;    /* GC pour l'inverse */
  47.     GC    bgc;    /* GC pour le bar */
  48.     GC    ugc;    /* Historique */
  49.     int     height_bar;
  50.     unsigned long top_shadow;
  51.     unsigned long bot_shadow;
  52.     XFontStruct *font;
  53.     unsigned long fg, bg;
  54. } ResourcesMenu;
  55.  
  56. /*
  57.  *    Structure des menus verticaux.
  58.  */
  59. typedef struct {
  60.     Window    v_frame;  /* La fenetre contenant les items */
  61.     Window    shadow;    /* La fenetre pour l'ombre */
  62.     Window    trans;    /* La fenetre mere */
  63.     Window    w_item [MAX_ITEMS];    /* Les items */
  64.     void (*func [MAX_ITEMS])();        /* Les callbacks */
  65.     int nb_items;            /* Le nombre d'items */
  66.     char **iname;    /* Les chaines de caracteres associes */
  67.     int x;        /* Position horizontale des menus */
  68.     int width, height;    /* Largeur et hauteur */
  69. } VMenu;
  70.  
  71. /*
  72.  *    Structure d'un menu XY
  73.  */
  74. typedef struct {
  75.     /*
  76.      *    La barre des titres.
  77.      */
  78.     Window w_bar;    /* La fenetre des titres */
  79.     Window parent;    /* Fille de root */
  80.     Window w_title [MAX_MENUS];     /* Le tableau des fenetres des titres */
  81.     int title_width [MAX_MENUS];    /* Le tableau des largeurs des titres */
  82.     int title_height;    /* La hauteur des titres en pixels */
  83.     int y_title;    /* La position des menus */
  84.     int bar_height, bar_width;    /* La largeur et la hauteur du bar */
  85.     /*
  86.      *    La fenetre masquee par les menus deroulants
  87.      */
  88.     Window w_under;    /* La fenetre masquee par les menus */
  89.     GC Ugc;        /* Le contexte graphique */
  90.     Pixmap save;    /* Si ya pas le save under */
  91.     int pix_width;
  92.     int save_ok;    /* Pour sauver une fois et une seule */
  93.     /*
  94.      *    Les Infos generales
  95.      */    
  96.     Window mapped;    /* Le menu mappe */
  97.     int n_last_mapped;    /* Le numero du menu mappe */
  98.     int n_last_unmapped; /* Le numero du dernier menu unmappe */
  99.     Window w_last_item; /* Le dernier item mappe */
  100.     int n_last_item;    /* Le numero du dernier item mappe */
  101.     int nb_menus;    /* Le nombre de menus */
  102.     VMenu *vmenu [MAX_MENUS];    /* Les menus verticaux */
  103.     char **titlename;    /* Les noms des menus */
  104.     char ***itemname;    /* Les noms des items */
  105.     int (***f_item) ();    /* Les callbacks associees */
  106.     unsigned int y_menu;    /* Position par rapport au parent */
  107.     int h_item;        /* Hauteur d'un item en pixels     */
  108.     int hmax_menu;        /* Hauteur du plus grand menu en pixels    */
  109.     XFontStruct *font;        /* La fonte */
  110.     GC Igc;            /* Le contexte graphique pour l'inverse*/
  111.     GC Ngc;            /* Le contexte graphique normal */
  112.     GC Bgc;            /* Le contexte graphique du bar */
  113.  
  114.     int width_relief;        /* Hauteur du relief    */
  115.     
  116.     unsigned long bg_bar;    /* La couleur du fond du bar */
  117.     unsigned long fg_bar;    /* La couleur du devant du bar     */
  118.     unsigned long bg_menu;    /* La couleur du font des menus */ 
  119.     unsigned long fg_menu;    /* La couleur du devant des menus */
  120.     int no_menu;        /* Le numero de menu courant     */
  121.     unsigned long   top_sh;
  122.     unsigned long   bot_sh;
  123. } XYMenu;
  124.  
  125. /*
  126.  *    Public
  127.  */
  128. extern void    InitMenusRes ( /*display, font, fg, bg, ts, bs */ );
  129. extern XYMenu     *MakeMenu ( /* display, w, font, title, item, fnt, fg, bg */ );
  130. extern int     MouseInMenuBar ( /* display, w */ );
  131. extern void     SetMenuPixmap ( /* display, menu, width */ );
  132. extern void     SetHiddenWindow ( /* menu, w, gc */ ); 
  133. extern void     RefreshMenuBar ( /* display, menu */ );
  134. extern int     ButtonPressInMenu ( /* w, menu */ );
  135. extern void     DeleteMenu ( /* display, menu */ );
  136. extern Window    HandleMenu ( /* display, ev, frame, menu, n, vm, item */ );
  137.  
  138. #define SetMenuBarWidth(m, x)    (m -> bar_width = x)
  139. #define GetMenuWindowBar(m) ( m -> w_bar )
  140. #define HeightMenuBar(font) ( (font -> ascent + font -> descent) + BAR_SPACE )
  141.  
  142. #endif /* _MENUS_H_ */
  143.